﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mcm="clr-namespace:Milkify.ComponentModel">
    <mcm:DateTimeValueConverter
        x:Key="TaskNoteDateConverter"
        Format="MMM dd @ HH:mm" />
    <mcm:BooleanToVisibilityConverter
        x:Key="CheckVisibilityConverter"
        FalseVisibility="Hidden" />
    <mcm:PriorityToVisibilityConverter
        x:Key="PriorityVisibilityConverter"
        NoPriorityVisibility="Hidden" />
    <mcm:BooleanToVisibilityConverter
        x:Key="RecurrenceVisibilityConverter"
        FalseVisibility="Hidden" />
    <DataTemplate x:Key="TaskListItem">
        <Grid
            Width="Auto"
            Height="Auto"
            Margin="{TemplateBinding Control.Padding}"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Name="Label" Width="*" />
                <ColumnDefinition Name="Count" Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Text="{Binding ListName}" Grid.Column="0" TextAlignment="Left" />
            <TextBlock Text="{Binding IncompleteTasksCount}" Grid.Column="1" TextAlignment="Right" />
        </Grid>
    </DataTemplate>
    <DataTemplate x:Key="TaskItem">
        <Grid
            Width="Auto"
            Height="Auto"
            Margin="{TemplateBinding Control.Padding}"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Name="ColumnCheckSelect" Width="Auto" />
                <ColumnDefinition Name="ColumnPriority" Width="Auto" />
                <ColumnDefinition Name="ColumnLabelAndParent" Width="*" />
                <ColumnDefinition Name="ColumnRecurrence" Width="Auto" />
                <ColumnDefinition Name="ColumnDue" Width="Auto" />
            </Grid.ColumnDefinitions>
            <CheckBox 
                Grid.Column="0" 
                Grid.RowSpan="2" 
                Name="CheckSelect"
                VerticalAlignment="Center"
                Margin="0,0,5,0"
                IsChecked="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"
                Visibility="{Binding Path=IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Converter={StaticResource CheckVisibilityConverter}}"
                Style="{DynamicResource TaskCheckBoxStyle}" />
            <Label
                Grid.Column="1"
                Grid.RowSpan="2"
                VerticalAlignment="Center"
                Content="{Binding Priority}"
                Visibility="{Binding Priority, Converter={StaticResource PriorityVisibilityConverter}}"
                Style="{DynamicResource TaskPriorityTextStyle}" />
            <Grid
                Grid.Column="2"
                Width="Auto"
                HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Text="{Binding Name}" TextWrapping="Wrap" />
                <TextBlock Grid.Row="1" Text="{Binding ParentName}" TextWrapping="NoWrap" />
            </Grid>
            <Label
                Grid.Column="3"
                Grid.RowSpan="2"
                VerticalAlignment="Center"
                Content="{Binding HasRecurrence}"
                Visibility="{Binding HasRecurrence, Converter={StaticResource RecurrenceVisibilityConverter}}"
                Style="{DynamicResource TaskRecurrenceIconStyle}" />
            <TextBlock 
                Grid.Column="4" 
                VerticalAlignment="Center" 
                Text="{Binding Due}" />
        </Grid>
    </DataTemplate>
    <DataTemplate x:Key="TaskNoteItem">
        <Grid
            Width="Auto"
            Height="Auto"
            Margin="{TemplateBinding Control.Padding}"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Name="TitleAndDate" Height="Auto" />
                <RowDefinition Name="BodyAbstract" Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Name="Title" Width="*" />
                <ColumnDefinition Name="Date" Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock
                Grid.Column="0" Grid.Row="0"
                Text="{Binding Title}"
                Style="{DynamicResource TaskNoteTitleStyle}" />
            <TextBlock
                Grid.Column="1" Grid.Row="0"
                Text="{Binding CreatedOrModified, Converter={StaticResource TaskNoteDateConverter}}"
                Style="{DynamicResource TaskNoteDateStyle}" />
            <TextBlock 
                Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"
                Text="{Binding Body}"
                Style="{DynamicResource TaskNoteBodyAbstractStyle}" />
        </Grid>
    </DataTemplate>
</ResourceDictionary>